//index.js
//获取应用实例
var app = getApp();
Page({
  data: {
    msgData: [],
    inputVal:''
  },
  changeInputValue:function(e) {
    // console.log(e)
    this.setData({
      inputVal: e.detail.value
    })
  },
  //添加留言
  addMsg:function() {
    // var list = this.data.msgData;
    // list.push({
    //   msg: this.data.inputVal
    // });
    
    //更新
    // this.setData({
    //   msgData: list,
    //   inputVal: ''
    // });
    var that=this
    var inputVal = this.data.inputVal
    var act_id = this.data.act_id
    var be_act_id = this.data.be_act_id
    // console.log(inputVal)
    if (inputVal==''){
      wx.showToast({
        title: '请写点什么吧',
        icon:'none'
      })
      return false
    } else if (inputVal.length>60){
      wx.showToast({
        title: '不能超过60字哦',
        icon: 'none'
      })
      return false
    }
    else{
      wx.request({
        url: app.globalData.url +'xcx/RandarAct',
        data: { act_id: act_id, be_act_id: be_act_id, act_num: 8, message: inputVal},
        method:"post",
        success:function(res){
            console.log(res)
            wx.showToast({
              title: '留言成功',
              icon:'success'
            })
            that.setData({
              inputVal:''
            })
        }
      })
    }



  },
  onLoad:function(e){
    console.log(e)
    this.setData({
      act_id: e.act_id,
      be_act_id: e.be_act_id
    })
  }
})